<template>
  <div>
    {{ data.city }}
  </div>
</template>

<script>
export default {
  mounted() {
    console.log(this.$route.params.id);
    this.getData();
    this.go();
  },
  data() {
    return {
      data: null,
      city: "",
    };
  },
  created() {
    this.city = this.$store.state.city;
  },
  methods: {
    go() {
      console.log(this.city);
      const url = `https://restapi.amap.com/v3/config/district?key=4a67e9a35fd3270bc528608920bab127&adcode=${this.city}&subdistrict=3`;
      console.log(url);
      this.axios.get(url).then((res) => {
        console.log(res);
      });
    },
    getData() {
      this.axios
        .get(`/user/detail?uid=${this.$route.params.id}`)
        .then((res) => {
          console.log(res);
          this.data = res.data.profile;
          console.log(this.data);
          this.$store.commit("updataData", this.data.city);
        });
    },
  },
};
</script>

<style lang="scss" scoped>
</style>